<?php
/**
 * @version		$Id: banner.php 14401 2010-01-26 14:10:00Z louis $
 * @package		Joomla
 * @subpackage	Banners
 * @copyright	Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
 * @license		GNU/GPL, see LICENSE.php
 * Joomla! is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 * See COPYRIGHT.php for copyright notices and details.
 */

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

/**
 * @package		Joomla
 * @subpackage	Banners
 */
class TableAlbuns extends JTable
{
					
	/** @var int */
	var $id				= null;
	/** @var string */
	var $tipo			= '';
	/** @var string */
	var $nome			= '';
	/** @var string */
	
	var $usu_id			= 0;
	/** @var int */
	var $dt_criacao			= null;
	/** @var int */
	var $final			= 0;
	/** @var string */
        var $imgdir			= '';
	/** @var string */
        var $id_dim			= 0;
	/** @var int */
        var $id_enc			= 0;
	/** @var int */
	var $obs			= '';
	/** @var string */

	function __construct( &$_db )
	{
		parent::__construct( 'albuns', 'id', $_db );


		$now =& JFactory::getDate();
		$this->set( 'dt_criacao', $now->toMySQL() );
	}

	function clicks()
	{
		$query = 'UPDATE #__banner'
		. ' SET clicks = ( clicks + 1 )'
		. ' WHERE bid = ' . (int) $this->bid
		;
		$this->_db->setQuery( $query );
		$this->_db->query();
	}

	/**
	 * Overloaded check function
	 *
	 * @access public
	 * @return boolean
	 * @see JTable::check
	 * @since 1.5
	 */
	function check()
	{      // print_r($this);
        //die;

		// check for valid client id
		if (is_null($this->usu_id) || $this->usu_id == 0) {
			$this->setError(JText::_( 'BNR_CLIENT' ));
			return false;
		}

		// check for valid name
		if(trim($this->nome) == '') {
			$this->setError(JText::_( 'BNR_NAME' ));
			return false;
		}

		
		/*if(trim($this->imageurl) == '') {
			$this->setError(JText::_( 'BNR_IMAGE' ));
			return false;
		}
		if(trim($this->clickurl) == '' && trim($this->custombannercode) == '') {
			$this->setError(JText::_( 'BNR_URL' ));
			return false;
		}*/

		return true;
	}
}
?>
